#include "io.h"
#include "../basic/types.h"
#include "../strings/printing.h"

uint64 r8(uint64 addr) {
  __try {
    return *(uint64 *)addr;
  } __except (1) {
    dbgprint("r8 读取异常!");
    return 0;
  }
}

uint32 r4(uint64 addr) {
  __try {
    return *(uint32 *)addr;
  } __except (1) {
    dbgprint("r4 读取异常!");
    return 0;
  }
}

uint16 r2(uint64 addr) {
  __try {
    return *(uint16 *)addr;
  } __except (1) {
    dbgprint("r2 读取异常!");
    return 0;
  }
}

uint8 r1(uint64 addr) {
  __try {
    return *(uint8 *)addr;
  } __except (1) {
    dbgprint("r1 读取异常!");
    return 0;
  }
}

float rfloat(uint64 addr) {
  __try {
    return *(float *)addr;
  } __except (1) {
    dbgprint("rfloat 读取异常!");
    return 0.f;
  }
}
